Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jshint improvements #26

Merged
merged 5 commits into from
Apr 25, 2015
Merged

Jshint improvements #26

merged 5 commits into from
Apr 25, 2015

Conversation

Graham42
Copy link
Contributor

This continues the work started by @baer in adamwdraper/Numeral-js#100. I adjusted the original proposal to be a little less strict because we need things like bitwise operators.

What's here now seems like a good starting point so I'm opening this PR for a place of discussion for how strict jshint rules should be.

baer and others added 4 commits April 21, 2015 19:04
`~~` operation is subtly different than `Math.floor`, it just removes
anything right of the decimal. This results in a difference for negative
numbers.

Also, `~~` is much faster than `Math.floor`.
As a highly performance oriented library, we definitely need to use
bitwise operations.

- Removed no longer supported jshint properties
- Remove several options that we're not using and are default to false
- Also add separate .jshintrc for test folder that extends the root
"curly" : true, // Require {} for every new block or scope.
"eqeqeq" : true, // Require triple equals i.e. `===`.
"es3" : false, // Adhere to ECMAScript 3 specification for legacy browsers like Internet Explorer 6/7/8.
"forin" : true, // Tolerate `for in` loops without `hasOwnPrototype`.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that should be false and forEach should be used instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The meaning of this is not which loop to use, but rather to enforce checking inside a for..in loop which is meant to make you check hasOwnProperty on keys of an object.

Also, forEach is actually not as fast as a regular for loop http://jsperf.com/for-vs-foreach/313.

BenjaminVanRyseghem added a commit that referenced this pull request Apr 25, 2015
@BenjaminVanRyseghem BenjaminVanRyseghem merged commit ce03ecf into BenjaminVanRyseghem:develop Apr 25, 2015
@BenjaminVanRyseghem
Copy link
Owner

👍

@Graham42 Graham42 deleted the tighten-jshint branch April 26, 2015 19:22
@BenjaminVanRyseghem
Copy link
Owner

In numbro 1.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants